﻿using Microsoft.AspNet.SignalR;
using RockBus.Logging.Interfaces;
using System.Reflection;
using System.Threading.Tasks;

namespace RockBus.Services.SignalR
{
    public abstract class RockBusHubBase : Hub
    {
        protected RockBusHubBase(ILogger logger)
        {
            this.Logger = logger;
        }

        private ILogger Logger { get; set; }

        public override Task OnConnected()
        {
            this.Logger.LogDebug(MethodBase.GetCurrentMethod(), "ConnectionId: {0}", this.Context.ConnectionId);
            return base.OnConnected();
        }

        public override Task OnDisconnected(bool stopCalled)
        {
            this.Logger.LogDebug(MethodBase.GetCurrentMethod(), "ConnectionId: {0}", this.Context.ConnectionId);
            return base.OnDisconnected(stopCalled);
        }

        public override Task OnReconnected()
        {
            this.Logger.LogDebug(MethodBase.GetCurrentMethod(), "ConnectionId: {0}", this.Context.ConnectionId);
            return base.OnReconnected();
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }
    }
}
